<?php

class WorkerCaselistController extends Controller
{
    /*
     * 获取列表
     *
     */
	public function actionGetList()
	{
        try
        {
            //参数验证

            //检测
            $user_id = SessionService::getUserIDBySessionid();

            //获取轮播图列表
            $searchsql= Util::initSearchSql();

            //排序
            $searchsql = $searchsql." order by publish_time  desc";
            //获取list
            $list = WorkerCaselist::model()->findAll($searchsql);


            //返回数据
            Util::responseList(count($list),$list);


        }catch (Exception $e)
        {
            Util::responseErrorMsg($e->getMessage());

        }
	}

    /*
     * 添加案例
     *
     */
    public function actionAddCase()
    {

        try
        {
            //检测
            $user_id = SessionService::getUserIDBySessionid();

            //参数验证
            $type_name = Util::getParamNotEmpty("type_name");
            $worker_name = Util::getParamNotEmpty("worker_name");
            $worker_avatar = Util::getParamNotEmpty("worker_avatar");
            $price = Util::getParamNotEmpty("price");
            $status = Util::getParamNotEmpty("status");
            $start_time = Util::getParamNotEmpty("start_time");
            $end_time = Util::getParamNotEmpty("end_time");
            $publish_time = Util::getParamNotEmpty("publish_time");
            $address = Util::getParamNotEmpty("address");
            $square = Util::getParamNotEmpty("square");
            $amount = Util::getParamNotEmpty("amount");
            $design_piclist = Util::getParamNotEmpty("design_piclist");
            $construction_piclist = Util::getParamNotEmpty("construction_piclist");



            //添加录播图
            $obj = new WorkerCaselist();
            Util::initObjData($obj);

            $obj->type_name = $type_name;
            $obj->worker_name = $worker_name;
            $obj->worker_avatar = $worker_avatar;
            $obj->price = $price;
            $obj->status = $status;
            $obj->start_time = $start_time;
            $obj->end_time = $end_time;
            $obj->publish_time = $publish_time;
            $obj->address = $address;
            $obj->square = $square;
            $obj->amount = $amount;
            $obj->design_piclist = $design_piclist;
            $obj->construction_piclist = $construction_piclist;

            Util::saveObjData($obj);



            //返回数据
            Util::responseMsg(MsgConst::RETURN_SUCCESS);


        }catch (Exception $e)
        {
            Util::responseErrorMsg($e->getMessage());

        }
    }

    /*
    * 删除
    */
    public function actionDelete()
    {

        try
        {
            //检测
            $user_id = SessionService::getUserIDBySessionid();

            //参数验证
            $obj_id = Util::getParamNotEmpty("obj_id");



            //删除
            $obj = WorkerCaselist::model()->findByPK($obj_id);

            Util::checkExistAndNotDelete($obj);

            Util::deleteObjData($obj);

            Util::saveObjData($obj);



            //返回数据
            Util::responseMsg(MsgConst::RETURN_SUCCESS);


        }catch (Exception $e)
        {
            Util::responseErrorMsg($e->getMessage());

    }
    }


    /*
     * 修改
     *
     */
    public function actionUpdate()
    {

        try
        {
            //检测
            $user_id = SessionService::getUserIDBySessionid();

            //参数验证
            $obj_id = Util::getParamNotEmpty("obj_id");
            $type_name = Util::getParamNotEmpty("type_name");
            $worker_name = Util::getParamNotEmpty("worker_name");
            $worker_avatar = Util::getParamNotEmpty("worker_avatar");
            $price = Util::getParamNotEmpty("price");
            $status = Util::getParamNotEmpty("status");
            $start_time = Util::getParamNotEmpty("start_time");
            $end_time = Util::getParamNotEmpty("end_time");
            $publish_time = Util::getParamNotEmpty("publish_time");
            $address = Util::getParamNotEmpty("address");
            $square = Util::getParamNotEmpty("square");
            $amount = Util::getParamNotEmpty("amount");
            $design_piclist = Util::getParamNotEmpty("design_piclist");
            $construction_piclist = Util::getParamNotEmpty("construction_piclist");



            //验证存在
            $obj = WorkerCaselist::model()->findByPK($obj_id);

            Util::checkExistAndNotDelete($obj);

            //修改信息

            $obj->type_name = $type_name;
            $obj->worker_name = $worker_name;
            $obj->worker_avatar = $worker_avatar;
            $obj->price = $price;
            $obj->status = $status;
            $obj->start_time = $start_time;
            $obj->end_time = $end_time;
            $obj->publish_time = $publish_time;
            $obj->address = $address;
            $obj->square = $square;
            $obj->amount = $amount;
            $obj->design_piclist = $design_piclist;
            $obj->construction_piclist = $construction_piclist;

            //保存
            Util::saveObjData($obj);



            //返回数据
            Util::responseMsg(MsgConst::RETURN_SUCCESS);


        }catch (Exception $e)
        {
            Util::responseErrorMsg($e->getMessage());

        }
    }

    /*
     * 1）图到代码技术的分析
熟悉UML状态图的组成和功能，掌握状态机，量子化平台(QP)，XML技术等关键技术知识，了解现阶段各种生成框架,研究如何通过状态图直接生成代码的可行性。
    2）代码生成器的设计与实现
    基于状态机，量子化平台(QP)等知识，通过OpenOffice软件绘制状态图中各元素信息，并分析每个元素对应xml文件的存储格式。
    根据状态图的存储方式，实现一种基于QP框架，可以将状态图存储的文件生成可执行代码的代码生成器。
    3）生成器功能的测试
    使用一个实际例子，绘制该例子对应的UML状态图，通过生成器将该状态图转换成可执行的代码，并进行执行，测试其执行的结果。
     *
     *
     *
     */







}